home *** CD-ROM | disk | FTP | other *** search
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * XMLFormatter.js
- *
- * USAGE
- * Part of Netobjects JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 2000-2005 Website Pros, Inc.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Website Pros, Inc.
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Website Pros, Inc.
- *
- * <copyright@websitepros.com>
- *
- * NOTES
- * JavaScript code.
- *
- *****/
-
- if (!IS_isModuleInitialized("IS.NOF.UTIL.LOGGING.XMLFormatter"))
- {
- /****h* NOF_JavaScript_Library/NOF.UTIL.LOGGING.XMLFormatter
- *
- * NAME
- * NOF.UTIL.LOGGING.XMLFormatter
- *
- * DESCRIPTION
- *
- * <code>XMLFormatter</code> is a <code>Formatter</code> designed to
- * format log messages using a XML representation.
- *
- *
- * var cfgLogger = NOF.UTIL.LOGGING.getLogger("myModuleName");
- * var cHndl = new NOF.UTIL.LOGGING.ConsoleHandler(cfgLogger);
- * cHndl.setFormatter( new NOF.UTIL.LOGGING.XMLFormatter() );
- * cfgLogger.addHandler( cHndl );
- * cfgLogger.warning(" {0} is {2} times stronger than {1}! ", "mySourceClass", "mySourceMethod", ["Superman", "Batman", 3] );
- * // will generate an output like:
- * // <logEntry><source><className>mySourceClass</className><methodName>mySourceMethod</methodName></source>
- * // <time>1062495263501</time><level>WARNING</level>
- * // <message> Superman is 3 times stronger than Batman! </message></logEntry>
- * // ...
- * try {
- * cHndl.close();
- * } catch (closing_e) {
- * // ...
- * }
- *
- ****/
-
- /**
- * constuctor
- **/
- function LOGGING_XMLFormatter( ) {
- this.__proto__ = LOGGING_XMLFormatter.prototype;
- this.SUPER();
- }
-
- LOGGING_XMLFormatter.inherits(LOGGING.Formatter)
- {
- var member = LOGGING_XMLFormatter.prototype;
- member.CLASS_NAME = "LOGGING.XMLFormatter";
-
- /**
- * string representing the DTD of the XML nodes
- * generated by this Formatter.
- **/
- member.DTD = "<!ELEMENT logEntry (source, time, level, message) >\
- <!ELEMENT source (className?, methodName?) >\
- <!ELEMENT className (#PCDATA) >\
- <!ELEMENT methodName (#PCDATA) >\
- <!ELEMENT time (#PCDATA) >\
- <!ELEMENT level (SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST) >\
- <!ELEMENT message (#PCDATA) >";
-
- var method = LOGGING_XMLFormatter.prototype;
-
- /**
- * Format a log record as a XML node.
- *
- * @param logRecord log message to be formatted
- * @return string representation of the XML node
- **/
- method.format = function (/*NOF.UTIL.LOGGING.LogRecord*/ logRecord) {
- var str = "<logEntry>";
- var sourceStr = "<source>";
- var tmpStr = logRecord.getSourceClassName();
- if (tmpStr != null) {
- sourceStr += "<className>" + tmpStr + "</className>";
- }
- tmpStr = logRecord.getSourceMethodName();
- if (tmpStr != null) {
- sourceStr += "<methodName>" + tmpStr + "</methodName>";
- }
- sourceStr += "</source>";
-
- str += (sourceStr + "<time>" + logRecord.getMillis() + "</time>" +
- "<level>" + LOGGING.Level.LEVEL_NAMES[logRecord.getLevel()] + "</level>"+
- "<message>" + this.formatMessage(logRecord) + "</message></logEntry>");
-
- return str;
- }
- }
- LOGGING.__proto__.XMLFormatter = LOGGING_XMLFormatter;
- }